#ifndef __MAIN_H__
#define __MAIN_H__

#include "BSP_timer.h"
#include "BSP_epwm.h"
#include "BSP_gpio.h"
#include "delay.h"
#include "Key.h"
#include "Nixie.h"
#include "BSP_adc.h"
#include "BSP_uart.h"
#include "stdio.h"
#include "main.h"
#include "APP.h"
#include "BSP_flash.h"

#define FLASH_LAST_PAGE			0x3C00											/* Flash最后一页    */
#define MAIN_TABLE_MAX			18												/* 主菜单选项最大值 */



/* 按键键值 */
#define KEY_UP					1
#define KEY_DOWN				2
#define KEY_TURN				3
#define KEY_SET					4

/* 主菜单选项 */
#define SV_MENU					GusMainMenuBuf[0]
#define AL1						GusMainMenuBuf[1]
#define AL2						GusMainMenuBuf[2]
#define AT						GusMainMenuBuf[3]
#define P						GusMainMenuBuf[4]
#define OH						GusMainMenuBuf[5]
#define I						GusMainMenuBuf[6]
#define D						GusMainMenuBuf[7]
#define Ar						GusMainMenuBuf[8]
#define T						GusMainMenuBuf[9]
#define SC						GusMainMenuBuf[10]
#define LCK						GusMainMenuBuf[11]
/* COD */
#define COD						GusMainMenuBuf[12]
/* 工程师菜单选项 */
#define SLL						GusMainMenuBuf[13]
#define SLH						GusMainMenuBuf[14]
#define AH1						GusMainMenuBuf[15]
#define AH2						GusMainMenuBuf[16]
#define DF						GusMainMenuBuf[17]

/* 主菜单选项索引 */
#define INDEX_SV_MENU				0
#define INDEX_AL1					1
#define INDEX_AL2					2
#define INDEX_AT					3
#define INDEX_P						4
#define INDEX_OH					5
#define INDEX_I						6
#define INDEX_D						7
#define INDEX_Ar					8
#define INDEX_T						9
#define INDEX_SC					10
#define INDEX_LCK					11
/* COD */
#define INDEX_COD					12
/* 工程师菜单选项索引 */
#define INDEX_SLL					13
#define INDEX_SLH					14
#define INDEX_AH1					15
#define INDEX_AH2					16
#define INDEX_DF					17

//指示灯状态显示位
#define FANRENHEIT					0x01
#define CENTIGRADE					0x04
#define ALM1						0x20
#define ALM2						0x10
#define OUT							0x08
#define AT_S						0x02

/* MODE菜单枚举 */
typedef enum
{
    MODE_SV_SHOW,				/* SV显示模式			 */
	MODE_SV_SET,				/* SV设置模式 			 */
	MAIN_MENU,					/* 主菜单模式			 */
	COD_MENU,					/* COD					 */
	ENG_MENU,					/* 工程师菜单			 */
}MODE_ENUM;

extern xdata uint16_t 				GusADC_Result;
extern int8_t 					i;
extern uint8_t 					GucSvSetSelect;
extern uint8_t 					GucSvSetFlashFlag;
extern int16_t 					GusSvValue;
extern int16_t 					GusPvValue;
extern MODE_ENUM 				MODE;
extern int8_t 					GcSvNixieBuf[];
extern int8_t 					GcPvNixieBuf[];
extern uint8_t 					GucKeyNum;
extern xdata uint8_t 					GucCountMenu;
extern xdata int16_t 			GusMainMenuBuf[];
extern xdata uint8_t 					GucMainMenuIndex;
extern uint8_t					GucSvSetSelect;
extern xdata uint8_t 			GucSvValueSign;
extern xdata uint8_t 			GucBackFlag;
extern xdata uint8_t 			GucPvSetADC_Flag;
extern xdata uint8_t 			GucPvSetATU_Flag;
extern xdata uint8_t 			GucRxBuf;
extern xdata float 				GsTemperature;
extern xdata uint8_t			GsLongKeyState;
extern xdata uint8_t			PID_Calculate_flag;


#endif

